# https://github.com/Karmenzind/

###########
#  boxes  #
###########

snippet lb "line box"
`!v printf(&cms . &cms, ' --------------------------------------------', ' ')`${1:${VISUAL}}
`!v printf(&cms, ' --------------------------------------------')`
endsnippet

snippet llb "long line box"
`!v printf(&cms . &cms, ' -----------------------------------------------------------------------------', ' ')`${1:${VISUAL}}
`!v printf(&cms, ' -----------------------------------------------------------------------------')`
endsnippet

###########
#  abbre  #
###########

snippet 192 ".168.0.1"
192.168.0.${1:1}
endsnippet

snippet lh "localhost"
http://localhost${1::80}
endsnippet

snippet 127 "localhost"
127.0.0.1
endsnippet

################
#  commentary  #
################

snippet 44 "line"
--------------------------------------------
endsnippet

snippet 77 "line"
-----------------------------------------------------------------------------
endsnippet

snippet /* "c style block commentary" w
/* ${1:${VISUAL}} */
endsnippet

##############
#  identity  #
##############

snippet gmail "valesail7" w
valesail7@gmail.com
endsnippet

snippet gh "my github" w
https://github.com/Karmenzind/
endsnippet

snippet ghr "github raw url" w
https://raw.githubusercontent.com/Karmenzind/
endsnippet

snippet kmz "my nickname" w
Karmenzind
endsnippet

##############
#  sequence  #
##############

global !p
def create_seq(snip):
    ph = snip.buffer[snip.line].strip()[1:]
    s, e, l = re.match('(\d+)[,-](\d+)[| ](.*)', ph).groups()
    body = snip.buffer[snip.line] = ''
    s, e = int(s), int(e)
    step = 1
    if e < s:
        e, s = s, e
        step = -1
    for i in range(s, e):
        body += l.format(N=i) + '\n'
    snip.expand_anon(body)
endglobal

pre_expand "create_seq(snip)"
snippet "s(\d+[,-]\d+[| ].*\{N\}.*)" "create a seq" br
endsnippet

##########
#  test  #
##########

# snippet t
# <tag>${VISUAL:inside text/should/is/g}</tag>
# endsnippet

# snippet dt
# `date +%d.%m.%y`
# endsnippet

##########
#  mark  #
##########

# TODO: <2018-10-24, k> 增加自动注释 #
snippet td "todo or other special comments"
${2:TODO}(${1:`echo $USER`}): <`date +%Y-%m-%d`> ${0:${VISUAL}}
endsnippet

snippet trm "to delete" b
These code has been modified or refactored and waiting to be deleted after testing.
此处已经修改或重构，测试稳定后删除原代码
endsnippet
